<!DOCTYPE html>
<html>

<head>
    <title>我的资料</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/plugins/jquery/jquery.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/myProfiles.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>

    <script>
        //查询粉丝数的方法
        function queryFans(concernedId, type) {
            $.get("/concerneds/" + concernedId, {type: type}, function (data) {
                if (type) {
                    $('#concerned').html(data);
                } else {
                    $('#fans').html(data);
                }

            })
        }

        $(function () {
            var userInfo=JSON.parse(sessionStorage.getItem("user"));
            $("#myConcernedLink").attr("href","/mine/myConcernedList.html?userId="+userInfo.id);
            $("#myFansLink").attr("href","/mine/myFansList.html?userId="+userInfo.id);
            //从sessionStorage中获取当前登录用户
            var user = JSON.parse(sessionStorage.getItem("user"));
            //查询出他的fans数
            queryFans(user.id)
            //查询出他关注的人数
            queryFans(user.id, "concerned")

            //渲染数据
            $(".info").renderValues(user);

            $("#sign").click(function () {
                $.post("/signs", function (data) {
                    if (data.success) {
                        $(document).dialog({
                            type: 'notice',
                            infoText: '签到成功!',
                            autoClose: 1000
                        });
                        $('#fa-calendar').removeClass("fa-calendar-times-o")
                        $('#fa-calendar').addClass("fa-calendar-check-o")
                        $('#sign').html("今日已签到")
                    } else {
                        $(document).dialog({
                            type: 'notice',
                            infoText: data.msg,
                            autoClose: 1000
                        });
                    }
                })
            })

            //获取当前用户的积分
            $.get("/exchanges",function (data) {
                //console.log(data);
                $(".list-inline-item").renderValues(data);
            })
            $.get("/signs",function (data) {
                if (!data.success) {
                    $('#fa-calendar').removeClass("fa-calendar-times-o")
                    $('#fa-calendar').addClass("fa-calendar-check-o")
                    $('#sign').html(data.msg)
                }
            })
            var user = JSON.parse(sessionStorage.getItem('user'));
            //传递当前userId
            $('#myComment').click(function () {
                var href = $(this).data('href');
                $(this).prop('href',href+'?userId='+user.id);
            })
        })
    </script>

</head>

<body>
<div class="nav-search">
    <a href="/index.html">
        <span><i class="fa fa-angle-left fa-2x"></i></span>
    </a>
</div>
<hr/>
<div class="container">
    <div class="row info">
        <div class="col-2" style="margin-right: 25px;">
            <img class="rounded-circle" render-src="headImgUrl">
        </div>
        <div class="col-8">
            <h5 render-html="nickName"></h5>
            <ul class="list-inline">
                <li class="list-inline-item">
                    <small>常住地</small>
                </li>
                <li class="list-inline-item">
                    <small render-html="place"></small>
                </li>
                <br>
                <li class="list-inline-item">
                    <a id="myConcernedLink"><small>关注<span id="concerned">0</span></small></a>
                </li>
                <li class="list-inline-item">
                    <a id="myFansLink"><small>粉丝<span id="fans">0</span></small></a>
                </li>
            </ul>
        </div>
    </div>

    <div class="d-flex setting">
        <div class="p-2 flex-fill">
            <a href="editTravels.html">
                <button class="btn">
                    <i class="fa fa-camera fa-fw"></i>
                    记录我的旅游日记
                </button>
            </a>
        </div>
        <div class="p-2 flex-fill">
            <a href="info.html">
                <button class="btn">编辑个人资料</button>
            </a></div>
    </div>

</div>

<hr/>

<div class="row link-box">
    <div class="col">
        <ul class="list-inline">
            <li class="list-inline-item"><i class="fa fa-shopping-bag fa-2x"></i></li>
            <li class="list-inline-item">
                <h7><a href="../integrationMall.html">积分商城</a></h7>
                <small>我的积分 <span render-html="points"></span></small>
            </li>
        </ul>
    </div>
    <div class="col">
        <ul class="list-inline">
            <li class="list-inline-item"><i class="fa fa-calendar-times-o fa-2x" id="fa-calendar"></i></li>
            <li class="list-inline-item">
                <h7 id="sign">每日签到</h7>
                <small>别忘了签到哦</small>
            </li>
        </ul>
    </div>
</div>
<hr/>
<ul class="mainmenu">
    <li><a href="/mine/collect.html"><b><i class="fa fa-star fa-2x"></i></b><span>我的收藏</span></a></li>
    <li><a data-href="/mine/myComment.html" id="myComment"><b><i class="fa fa-commenting-o fa-2x"></i></b><span>我的评论</span></a></li>
    <li><a href="/mine/travels.html"><b><i class="fa fa-book fa-2x"></i></b><span>我的游记</span></a></li>
    <li><a href="#"><b><i class="fa fa-list-ul fa-2x"></i></b><span>我的心愿单</span></a></li>
    <li><a href="/mine/message.html"><b><i class="fa fa-bullhorn fa-2x"></i></b><span>我的消息</span></a></li>
    <li><a href="/mine/MyOrder.html"><b><i class="fa fa-file-text fa-2x"></i></b><span>我的订单</span></a></li>
    <li><a href="#"><b><i class="fa fa-briefcase fa-2x"></i></b><span>我的钱包</span></a></li>
    <li><a href="/question.html"><b><i class="fa fa-comments fa-2x"></i></b><span>社区问答</span></a></li>
</ul>

</body>

</html>